//
//  AppDelegate.m
//  TOUTIAO
//
//  Created by duyujin1 on 2021/8/1.
//

#import "AppDelegate.h"
#import "DUNewsViewController.h"
#import "DUVideoViewController.h"
#import "DURecommendViewController.h"
#import "DUMineViewController.h"
#import "DUTabBarController.h"
#import "DUSplashView.h"
#import "DULocation.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    DUTabBarController * tabbar=[[DUTabBarController alloc] init];
    self.window.rootViewController=[[UINavigationController alloc] initWithRootViewController:tabbar];
    [self.window makeKeyAndVisible];
    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) {
       [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
       [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"first"];
    }
    else{
       [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"first"];
    }
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"first"]) {
       // 首次使用增加自定义启动页
        DUSplashView * splashView=[[DUSplashView alloc] initWithFrame:self.window.bounds];
        [self.window addSubview:splashView];
    }else{
        //非首次使用隐藏
    }
    [[DULocation locationManager] checkLocationAuthorization];
    return YES;
}
//设置URL types，使app支持scheme被唤起
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
    return YES;
}

@end
